package Work1;
import java.util.Random;
import java.util.Scanner;

public class RandomOperator {
	public static void main(String[] args) {
		Random rd = new Random();
		Scanner sc = new Scanner(System.in);
		int firstnum;
		int secondnum;
		int operator;
		int result;
		int answer;
		int right=0;
		System.out.println("数据类型为整型");
		for(int i=0;i<10;i++) {
			firstnum = rd.nextInt(100);
			secondnum = rd.nextInt(100);
			operator = rd.nextInt(4);
			switch (operator) {
			case(0) :
				System.out.println(firstnum+"+"+secondnum);
				result = firstnum + secondnum;
			break;
			case(1) :
				System.out.println(firstnum+"-"+secondnum);
				result = firstnum - secondnum;
			break;
			case(2) :
				System.out.println(firstnum+"*"+secondnum);
				result = firstnum * secondnum;
			break;
			case(3) :
				 while (secondnum == 0) { 
				        secondnum = rd.nextInt(100);
				    }
				System.out.println(firstnum+"/"+secondnum);
				result = firstnum / secondnum;
			break;
			default :
				System.out.println("ERROR!");
				result = 0;
			}
			System.out.println("请输入结果：");
			answer=sc.nextInt();
			if( answer == result ) {
				System.out.println("回答正确");
				right++;
			}else {
				System.out.println("回答错误");
			}
		}
		System.out.println("共答对"+right+"道,答错"+(10-right)+"道");

	}
}
